import typescript from '@rollup/plugin-typescript';
import { terser } from 'rollup-plugin-terser';
import postcss from 'rollup-plugin-postcss';
import pkg from './package.json';

// 检查是否为生产环境
const isProduction = process.env.NODE_ENV === 'production';

// 配置TypeScript插件
const typescriptPlugin = isProduction 
  ? { 
      // 生产环境下跳过严格类型检查
      noEmitOnError: true,
      tsconfig: './tsconfig.json'
    }
  : { tsconfig: './tsconfig.json' };

export default [
  // UMD版本
  {
    input: 'src/index.ts',
    output: {
      file: 'dist/airdrop-modal.umd.js',
      format: 'umd',
      name: 'AirdropModal',
      exports: 'named',
      sourcemap: true
    },
    plugins: [
      typescript(typescriptPlugin),
      postcss({
        extract: false,
        modules: false,
        inject: true,
        minimize: true
      }),
      terser()
    ]
  },
  // ES模块版本
  {
    input: 'src/index.ts',
    output: {
      file: 'dist/airdrop-modal.esm.js',
      format: 'es',
      exports: 'named',
      sourcemap: true
    },
    plugins: [
      typescript(typescriptPlugin),
      postcss({
        extract: false,
        modules: false,
        inject: true,
        minimize: true
      }),
      terser()
    ]
  }
]; 